#include <stdio.h>
#include "ofc/DBigFraction.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DBIGFRACTION
  DBigFraction *fra1 = [DBigFraction alloc];
  DBigFraction *fra2 = [DBigFraction new  ];
  DBigFraction *fra3 = [DBigFraction new  ];
  DText        *str;

  [fra1 init :"6/4" :10];           // Init fraction with 6/4 (base 10)

  [fra2 fraction :8 :10];           // Set fraction with 8/10

  [fra2 mul :fra1];                 // fra2 = fra2 * fra1

  [fra3 sub :fra2 :fra1];           // fra3 = fra2 - fra1

  printf("Fraction (as double):%f\n", [fra3 get]);  // Get fraction as double

  str = [fra3 get :10];             // Get fraction as string, base 10
  printf("Fraction (as string):%s\n", [str cstring]);

  if ([fra1 compare :fra2] == 0)    // Compare numbers
    printf("Fraction1 is equal to fraction2\n");
  else if ([fra1 compare :fra2] < 0)
    printf("Fraction1 is smaller than fraction2\n");
  else
    printf("Fraction1 is greater than fraction2\n");

  [str  free];                      // Cleanup
  [fra3 free];
  [fra2 free];
  [fra1 free];
#else
  printf("DBigFraction is not present in the library.\n");
#endif
  return 0;
}

